<script>
    $(document).ready(function(){

        $("input[type=checkbox]").click(
        
        function() {
            
            if($(this).attr('class')=='tipo3'){
                $("#calificacion").attr("value", 3);
                $(".tipo1").attr("checked",false);
                $(".tipo2").attr("checked",false);
            }else{
                if($(this).attr('class')=='tipo2'){
                    $("#calificacion").attr("value", 2);
                    $(".tipo1").attr("checked",false);
                    $(".tipo3").attr("checked",false);
                }else
                    if($(this).attr('class')=='tipo1'){
                        $("#calificacion").attr("value", 1);
                        $(".tipo2").attr("checked",false);
                        $(".tipo3").attr("checked",false);
                    }

            }

        }
    )
    });
</script>

<?php
echo $this->Form->create('CandidateRequirement');
echo $this->Form->input("CandidateRequirement.id");
echo $this->Form->hidden("CandidateRequirement.candidate_id");
?>
<h1><?php echo $this->data['Candidate']['1er_nombre'] . "  " . $this->data['Candidate']['1er_apellido'] ?></h1>
<br>

<h1><?php echo $this->data['Requirement']['texto'] ?></h1>
<br>
<table border="1" width="100%" >
    <tbody>
        <?php
        foreach ($condiciones as $con):
            $ch = "";


            foreach ($chequeados as $val) {
                // echo $con['RequirementFault']['id']." ".$val['CandidateRequirementsRequirementFault']['requirement_fault_id']."<br>";
                if ($con['RequirementFault']['id'] == $val['CandidateRequirementsRequirementFault']['requirement_fault_id']) {
                    $ch = "checked";
                }
            }
            ?>
            <tr>
                <td width="20%"><?php echo $this->Form->input("RequirementFault.id", array('type' => 'checkbox', 'label' => '', 'class' => 'tipo' . $con['RequirementFault']['tipo'], 'value' => $con['RequirementFault']['id'], 'name' => 'checked[]', 'checked' => $ch)); ?></td>
                <td width="80%" style="text-align: justify"><label><?php echo $con['RequirementFault']['nombre'] ?></label></td>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<?php
echo $this->Form->hidden("CandidateRequirement.calificacion", array('id' => 'calificacion'));
?>

<?php
if ($this->Session->read('estado') == 0)
    echo $ajax->submit('Guardar', array('url' => array('controller' => 'CandidateRequirements', 'action' => 'edit'), 'update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading'));
echo $this->Form->end();
echo $ajax->link("REGRESAR", array('controller' => 'CandidateRequirements', "action" => "index", $this->data['CandidateRequirement']['candidate_id']), array('update' => 'content', 'complete' => 'cargar()'))
?>